package com.lipaluma.field.mapper.single.impl;

import java.lang.reflect.Field;

import com.lipaluma.annotations.validations.ValidateDecimal;
import com.lipaluma.context.Context;
import com.lipaluma.field.mapper.mapping.FieldMappingInfo;
import com.lipaluma.field.validator.ChainValidator;
import com.lipaluma.field.validator.ValidationBasicOptions;
import com.lipaluma.field.validator.ValidatorFactory;
import com.lipaluma.xml.mapping.XmlFieldMapping;

public class DecimalFieldMapper extends AbstractNumericFieldMapper {

	public DecimalFieldMapper() {}
	/**
	 * Field Mapper that parses a numeric value
	 * @param mapping information of mapping
	 */
	public DecimalFieldMapper(FieldMappingInfo mapping) {
		super(mapping);
	}
	
	/**
	 * Field Mapper that parses a numeric value
	 * @param mapping information of mapping
	 * @param pattern pattern of the numeric value
	 */
	public DecimalFieldMapper(FieldMappingInfo mapping, String pattern) {
		super(mapping, pattern);
	}

	public ChainValidator createChainValidator(Context context, Field field) {
		ValidationBasicOptions validationOptions = ValidationBasicOptions.builder().byAnnotation(field.getAnnotation(ValidateDecimal.class)).build();
		return ValidatorFactory.createNewChainValidator(context, field, validationOptions);
	}

	public ChainValidator createChainValidator(Context context, Field field, XmlFieldMapping mapping) {
		return ValidatorFactory.createNewChainValidator(context, field, mapping);
	}

}
